import java.util.Random;

public class App {
    public static void main(String[] args) throws Exception {
       Random r = new Random();
        Human h1 = new Human();
        int i = 0;
        String[] name_list1 = {"张","李","王","老","毛","叶","洪","彭"};//姓列表
        String[] name_list2 = {"大","贰","叁","伍","留","柒","捌","玖"};//名列表
        String name;

        //姓名随机生成
        i = r.nextInt(name_list1.length);//确定姓氏
        name = name_list1[i];
        i = r.nextInt(name_list2.length);//确定名字
        name += name_list2[i];//组成姓名
        h1.setname(name);//登记姓名

        //性别随机生成
        char[] gender_list = {'男','女','?'};//性别列表
        i = r.nextInt(gender_list.length);
        h1.setgender(gender_list[i]);//登记性别

        //身高+年龄随机生成

            //年龄参数设置
        int age_base;
        int age_or = 500;
        if(h1.getgender() == '女')
        {
            age_base = 1450;
        }
        else if(h1.getgender() == '男')
        {
            age_base = 1550;
        }
        else
        {
            age_base = 0;
            age_or = 10000;
        }
        i = r.nextInt(age_or) + age_base;//结算年龄

            //身高更根据性别调整尺度
        String unit = "cm";
        if(h1.getgender() == '?')
        {
            unit = "m";//更改长度单位
            h1.sethight((double)i / 100);//0 ~ 100 m
            i = r.nextInt(10000);//0 ~ 10000岁

        }
        else
        {
            h1.sethight((double)i / 10);//男：155.0 ~ 205.0 cm  /  女：145.0 ~ 195.0 cm
            i = r.nextInt(61) + 12;//12 ~ 61
        }
        h1.setage(i);//登记年龄

        //打印随机生成的角色结果
        System.out.printf("\n姓名: %s\n年龄: %d\n性别: %c\n身高: %.1f %s\n",h1.getname(),h1.getage(),h1.getgender(),h1.gethight(),unit);
    }
}
